package com.fastCms.business.bim.enums;


import com.fastCms.business.frame.pojo.vo.EnumDataVO;

import java.util.ArrayList;
import java.util.List;

/**
 * 哈密瓜科技 版权所有 © Copyright 2019<br>
 *
 * @Description: 设备大类<br>
 * @Project: hami <br>
 * @CreateDate: Created in 2019/3/7 下午3:48 <br>
 * @Author: <a href="lsquan666@163.com">lsquan</a>
 */
public enum ListenBusiType {
    TSP("TSP", "TSP"),
    PM25("PM25", "PM25"),
    PM10("PM10", "PM10");

    private String code;
    private String name;

    ListenBusiType(String code, String name) {
        this.code = code;
        this.name = name;
    }

    public static ListenBusiType getEnum(String code) {
        for (ListenBusiType item : ListenBusiType.values()) {
            if (item.code.equals(code)) {
                return item;
            }
        }
        return null;
    }

    /**
     * 根据code获取name
     *
     * @param code
     * @return
     */
    public static String getName(String code) {
        ListenBusiType item = getEnum(code);
        return item != null ? item.name : null;
    }


    public String getCode() {
        return code;
    }

    public void setCode(String key) {
        this.code = key;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public static List<EnumDataVO> getEnumVOs() {
        List<EnumDataVO> enumVOS = new ArrayList<>();
        for (ListenBusiType item : ListenBusiType.values()) {
            EnumDataVO enumVO = new EnumDataVO();
            enumVO.setCode(item.getCode());
            enumVO.setName(item.getName());
            enumVOS.add(enumVO);
        }
        return enumVOS;
    }

}
